package com.jse.tpl;

import java.io.IOException;
import java.util.Date;

import com.jse.Times;

/**
 * Writer
 */
public abstract class AWriter implements AutoCloseable {
	
//	protected DateFormats formats = new DateFormats();
	
	public abstract void flush() throws IOException;
	
	public abstract void write(Text writable) throws IOException;
	
	public abstract void write(String string, int offset, int length) throws IOException;
	
	public abstract void write(String string) throws IOException;
//	
	public abstract void write(StringBuilder stringBuilder, int offset, int length) throws IOException;
	
	public abstract void write(StringBuilder stringBuilder) throws IOException;
//	
//	public abstract void write(boolean booleanValue) throws IOException;
//	
//	public abstract void write(int intValue) throws IOException;
//	
//	public abstract void write(long longValue) throws IOException;
//	
//	public abstract void write(double doubleValue) throws IOException;
//	
//	public abstract void write(float floatValue) throws IOException;
	
//	public void write(short shortValue) throws IOException {
//		write((int)shortValue);
//	}
	
	public void write(Date date, String datePattern) throws IOException {
		String str = Times.format(date,datePattern);
		write(str, 0, str.length());
	}
	
	/**
	 * 格式化输出 LocalDateTime、LocalDate、LocalTime
	 */
	public void write(java.time.temporal.Temporal temporal, String pattern) throws IOException {
		write(Times.format(pattern,temporal));
	}
}







